/**
 * 
 */
package co.edu.udem.service.subject;

import java.util.ArrayList;
import java.util.List;

import co.edu.udem.domain.Subject;
import co.edu.udem.domain.UserSubject;
import co.edu.udem.service.GenericDTO;


/**
 * @since 29/07/2012
 */
public class SubjectDTO extends GenericDTO {

  private String subjectCode;

  private String subjectName;

  private String teacherCode;

  private String teacherName;

  private String subjectPeriod;

  private Float grade1;

  private Float grade2;

  private Float grade3;

  private Float grade4;

  private Float finalGrade;

  private Float definitiveGrade;

  /*
   * (non-Javadoc)
   * 
   * @see co.edu.udem.service.GenericDTO#writeValuesToStringBuilder(java.lang.StringBuilder)
   */
  @Override
  public void writeValuesToStringBuilder(StringBuilder stringBuilder) {
    stringBuilder.append(this.getSubjectCode() == null ? " NULL, " : appendValueFormat(this.getSubjectCode(), true));
    stringBuilder.append(this.getSubjectName()== null ? " NULL, " : appendValueFormat(this.getSubjectName(), true));
    stringBuilder.append(this.getTeacherCode() == null ? " NULL, " : appendValueFormat(this.getTeacherCode(), true));
    stringBuilder.append(this.getTeacherName() == null ? " NULL, " : appendValueFormat(this.getTeacherName(), true));
    stringBuilder.append(this.getSubjectPeriod() == null ? " NULL, " : appendValueFormat(this.getSubjectPeriod(), true));
    stringBuilder.append(this.getGrade1() == null ? " NULL," : this.getGrade1()  + ", ");
    stringBuilder.append(this.getGrade2() == null ? " NULL," : this.getGrade2()  + ", ");
    stringBuilder.append(this.getGrade3() == null ? " NULL," : this.getGrade3()  + ", ");
    stringBuilder.append(this.getGrade4() == null ? " NULL," : this.getGrade4()  + ", ");
    stringBuilder.append(this.getFinalGrade() == null ? " NULL," : this.getFinalGrade()  + ", ");
    stringBuilder.append(this.getDefinitiveGrade() == null ? " NULL" : this.getDefinitiveGrade() );
  }

  public static List<GenericDTO> populateDTOList(List<Object[]> subjectList) {
    List<GenericDTO> subjectDTOList = new ArrayList<GenericDTO>();

    if (subjectList != null && !subjectList.isEmpty()) {
      SubjectDTO subjectDTO;
      for (Object[] object : subjectList) {
        subjectDTO = new SubjectDTO();
        subjectDTO.setSubjectCode(((Subject) object[0]).getSubjectCode());
        subjectDTO.setSubjectPeriod(((Subject) object[0]).getSubjectPeriod());
        subjectDTO.setSubjectName(((Subject) object[0]).getSubjectName());
        subjectDTO.setTeacherCode(((Subject) object[0]).getTeacherCode());
        subjectDTO.setTeacherName(((Subject) object[0]).getTeacherName());
        
        subjectDTO.setDefinitiveGrade(((UserSubject) object[1]).getDefinitiveGrade());
		subjectDTO.setFinalGrade(((UserSubject) object[1]).getFinalGrade());
		subjectDTO.setGrade1(((UserSubject) object[1]).getGrade1());
		subjectDTO.setGrade2(((UserSubject) object[1]).getGrade2());
		subjectDTO.setGrade3(((UserSubject) object[1]).getGrade3());
		subjectDTO.setGrade4(((UserSubject) object[1]).getGrade4());
        subjectDTOList.add(subjectDTO);
      }
    }
    return subjectDTOList;
  }

  /**
   * @return the subjectCode
   */
  public String getSubjectCode() {
    return subjectCode;
  }

  /**
   * @param subjectCode the subjectCode to set
   */
  public void setSubjectCode(String subjectCode) {
    this.subjectCode = subjectCode;
  }

  /**
   * @return the subjectName
   */
  public String getSubjectName() {
    return subjectName;
  }

  /**
   * @param subjectName the subjectName to set
   */
  public void setSubjectName(String subjectName) {
    this.subjectName = subjectName;
  }

  /**
   * @return the teacherCode
   */
  public String getTeacherCode() {
    return teacherCode;
  }

  /**
   * @param teacherCode the teacherCode to set
   */
  public void setTeacherCode(String teacherCode) {
    this.teacherCode = teacherCode;
  }

  /**
   * @return the teacherName
   */
  public String getTeacherName() {
    return teacherName;
  }

  /**
   * @param teacherName the teacherName to set
   */
  public void setTeacherName(String teacherName) {
    this.teacherName = teacherName;
  }

  /**
   * @return the subjectPeriod
   */
  public String getSubjectPeriod() {
    return subjectPeriod;
  }

  /**
   * @param subjectPeriod the subjectPeriod to set
   */
  public void setSubjectPeriod(String subjectPeriod) {
    this.subjectPeriod = subjectPeriod;
  }

  /**
   * @return the grade1
   */
  public Float getGrade1() {
    return grade1;
  }

  /**
   * @param grade1 the grade1 to set
   */
  public void setGrade1(Float grade1) {
    this.grade1 = grade1;
  }

  /**
   * @return the grade2
   */
  public Float getGrade2() {
    return grade2;
  }

  /**
   * @param grade2 the grade2 to set
   */
  public void setGrade2(Float grade2) {
    this.grade2 = grade2;
  }

  /**
   * @return the grade3
   */
  public Float getGrade3() {
    return grade3;
  }

  /**
   * @param grade3 the grade3 to set
   */
  public void setGrade3(Float grade3) {
    this.grade3 = grade3;
  }

  /**
   * @return the grade4
   */
  public Float getGrade4() {
    return grade4;
  }

  /**
   * @param grade4 the grade4 to set
   */
  public void setGrade4(Float grade4) {
    this.grade4 = grade4;
  }

  /**
   * @return the finalGrade
   */
  public Float getFinalGrade() {
    return finalGrade;
  }

  /**
   * @param finalGrade the finalGrade to set
   */
  public void setFinalGrade(Float finalGrade) {
    this.finalGrade = finalGrade;
  }

  /**
   * @return the definitiveGrade
   */
  public Float getDefinitiveGrade() {
    return definitiveGrade;
  }

  /**
   * @param definitiveGrade the definitiveGrade to set
   */
  public void setDefinitiveGrade(Float definitiveGrade) {
    this.definitiveGrade = definitiveGrade;
  }

}
